package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class Demo5 {
    public static void main(String[] args) {
        try(Connection connection = DEUtil.getConnection()) {
            Statement statement = connection.createStatement();
            String sql = "SELECT c.name  ,c.floor ,t.name ,t.salary  " +
                    "FROM class c " +
                    "RIGHT JOIN teacher t  ON c.teacher_id = t.id ";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()){
                String name2 = resultSet.getString("c.name");
                String floor = resultSet.getString("c.floor");
                 String name = resultSet.getString("t.name");
                double salary = resultSet.getDouble("t.salary");
                System.out.println(name2+" "+floor+" "+name+" "+salary);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
